package com.mjh.action;

import java.util.ArrayList;
//import org.apache.log4j.Logger;
import com.opensymphony.xwork2.ActionSupport;
import com.mjh.bean.*;
import com.mjh.manager.*;

public class TaskAction extends ActionSupport{

	private static final long serialVersionUID = 1L;

	//private static Logger log = Logger.getLogger(TaskAction.class);
	
	private ArrayList<Task> taskList;
	
	private String taskId;
	
	private int result;
	
	public String list(){
		taskList = TaskManager.getInstance().getTasksList();
		return SUCCESS;
	}
	
	public String start(){
		if(taskId == null) {
			return SUCCESS;
		}
		result = TaskManager.getInstance().startTask(taskId);
		return SUCCESS;
	}
	
	public String stop(){
		if(taskId == null) {
			return SUCCESS;
		}
		result = TaskManager.getInstance().stopTask(taskId);
		return SUCCESS;
	}
	
	public String executeTask(){
		if(taskId == null) {
			return SUCCESS;
		}
		result = TaskManager.getInstance().excuteTask(taskId);
		return SUCCESS;
	}

	public String startAll(){
		result = TaskManager.getInstance().startAll();
		return SUCCESS;
	}
	
	public String stopAll(){
		result = TaskManager.getInstance().stopAll();
		return SUCCESS;
	}
	
	public String reload(){
		result = TaskManager.getInstance().reloadTask();
		return SUCCESS;
	}
	public ArrayList<Task> getTaskList() {
		return taskList;
	}

	public void setTaskList(ArrayList<Task> taskList) {
		this.taskList = taskList;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public int getResult() {
		return result;
	}

	public void setResult(int result) {
		this.result = result;
	}
}
